package priv.lhy.activity.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import priv.lhy.activity.commons.ResultResp;
import priv.lhy.activity.controller.support.ResponseData;
import priv.lhy.activity.draw.IActivityTurntableDrawService;
import priv.lhy.activity.draw.bean.ActivityTurntableDrawReq;
import priv.lhy.activity.draw.bean.AwardDrawRecordBean;

/**
 * author : lihy
 * date : 2019/2/20 13:23
 */
@Controller
public class DrawController extends BaseController {

    @Autowired
    IActivityTurntableDrawService activityTurntableDrawService;

    /**
     * 抽奖
     * @return
     */
    @PostMapping("/doDraw")
    public @ResponseBody ResponseData doDraw() {
        ActivityTurntableDrawReq drawReq = new ActivityTurntableDrawReq();
        drawReq.setUid(Integer.parseInt(getUid()));
        ResultResp<AwardDrawRecordBean> resp = activityTurntableDrawService.doDraw(drawReq);
        ResponseData data = new ResponseData();
        data.setCode(resp.getReturnCodeEnum().getCode());
        data.setMessage(resp.getReturnCodeEnum().getMsg());
        data.setData(resp.getResult());
        System.out.println(data.toString());
        return data;
    }

    @RequestMapping("/activityPage")
    public String drawPage(){
        return "activity";
    }
}
